package es.uclm.itsue.SQLite;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class BibliotecaSQLiteHelper extends SQLiteOpenHelper {

	public BibliotecaSQLiteHelper(Context context, String name, CursorFactory factory, int version) {
		super(context, name, factory, version);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL("CREATE TABLE libros (_id INTEGER PRIMARY KEY AUTOINCREMENT, titulo TEXT, autor TEXT)");     
		db.execSQL("CREATE TABLE lectores (_id INTEGER PRIMARY KEY AUTOINCREMENT, nombre TEXT, dni NUMERIC)");
	} 

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		db.execSQL("DROP TABLE IF EXISTS libros");
		db.execSQL("DROP TABLE IF EXISTS lectores");
		onCreate(db);
	}
	
	public void onOpen(SQLiteDatabase db){
		Log.i("BDHelper", "Base de datos Biblioteca abierta");
	}
}
